﻿using Microsoft.AspNetCore.Mvc;
using PowerHub.MES.Common.Utility;
using PowerHub.MES.DTO.Crew.DTO;
using PowerHub.MES.DTO.Crew.QueryDto;
using PowerHub.MES.DTO.Production.DTO;
using PowerHub.MES.DTO.Production.QueryDTO;
using PowerHub.MES.Entities.Crew;
using PowerHub.MES.Entities.Production;
using PowerHub.MES.IServices.ICrew;
using PowerHub.MES.IServices.IProduction;
using PowerHub.MES.ReturnEntity;

namespace PowerHub.MES.Controllers.Production
{

    /// <summary>
    /// 生产任务
    /// </summary>
    [ApiController]
    [Route("Api/MES/Production/[controller]/[action]")]
    public class ProductionTaskController
    {

        private IProduction_ProductionTaskServices _Production_ProductionTaskServices;

        public ProductionTaskController(IProduction_ProductionTaskServices ProductionTaskServices)
        {
            _Production_ProductionTaskServices = ProductionTaskServices;
        }

        /// <summary>
        /// 获取生产任务列表
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("获取生产任务列表")]
        public async Task<OperationPageResult<List<Production_ProductionTask>>> GetProduction_ProductionTaskPageListAsync([FromBody] QueryProduction_ProductionTaskDTO pageQuery)
        {
            return await _Production_ProductionTaskServices.GetProduction_ProductionTaskPageListAsync(pageQuery);
        }


        /// <summary>
        /// 批量删除生产任务
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("批量删除生产任务")]
        public async Task<OperationResult<bool>> DeletionProduction_ProductionTaskAsync([FromBody] List<string> Query)
        {
            return await _Production_ProductionTaskServices.DeletionProduction_ProductionTaskAsync(Query);
        }

        /// <summary>
        /// 更新生产任务
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("更新生产任务")]
        public async Task<OperationResult<bool>> UpdateProduction_ProductionTaskAsync([FromBody] Production_ProductionTaskDTO Query)
        {
            return await _Production_ProductionTaskServices.UpdateProduction_ProductionTaskAsync(Query);
        }

        /// <summary>
        /// 添加生产任务
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("添加生产任务")]
        public async Task<OperationResult<bool>> CreateProduction_ProductionTaskAsync([FromBody] Production_ProductionTaskDTO Query)
        {
            return await _Production_ProductionTaskServices.CreateProduction_ProductionTaskAsync(Query);
        }
        /// <summary>
        /// 根据计划明细id添加生产任务（单）
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("根据计划明细id添加生产任务（单）")]
        public async Task<OperationResult<bool>> CreateProduction_ProductionTaskBySchedulingPlanDetialIdAsync([FromBody] Production_ProductionTaskByDetialDTO Query)
        {
            return await _Production_ProductionTaskServices.CreateProduction_ProductionTaskBySchedulingPlanDetialIdAsync(Query);
        }
    }
}
